import fetch from './util/fetch';

/**
 * 维修列表
 * tab : repair 待维修 repairing 维修中  repaired 维修完成
 * */
export function getRepairList(data) {
  return fetch({
    url: 'serviceOrders/'+data.tab+'/repairList',
    method: 'get',
    params: data,
  });
}

/**
 * 拒绝维修
 * */
export function refuseRepair(data) {
  return fetch({
    url: 'serviceOrders/refuseRepair/' + data.serviceOrderId,
    method: 'put',
    data: data,
  });
}

/**
 * 同意维修
 * */
export function agreeRepair(data) {
  return fetch({
    url: 'serviceOrders/agreeRepair/' + data.serviceOrderId,
    method: 'put',
    data: data,
  });
}

/**
 * 维修和退货确认收货
 * */
export function confirmReceive(data) {
  return fetch({
    url: 'serviceOrders/confirmReceive/' + data.serviceOrderId,
    method: 'put',
    data: data,
  });
}

/**
 * 维修完成和换货的发货
 * */
export function serviceDeliver(data) {
  return fetch({
    url: 'serviceOrders/sendBack/' + data.serviceOrderId,
    method: 'post',
    data: data,
  });
}


/**
 * 退货列表
 * tab : return 待退货  returning 退货中 returned 退货已完成 refunding 退款中
 * */
export function getReturnList(data) {
  return fetch({
    url: 'serviceOrders/'+data.tab+'/returnList',
    method: 'get',
    params: data,
  });
}


/**
 * 换货列表
 * tab : exchange 待换货 exchanging 换货中 exchanged 换货已完成
 * */
export function getChangeList(data) {
  return fetch({
    url: 'serviceOrders/'+data.tab+'/exchangeList',
    method: 'get',
    params: data,
  });
}

/**
 * 售后物流详情
 * type : user 商户发给用户的物流详情  merchant 商户发给用户的物流详情
 * */
export function getServiceExpress(data) {
  return fetch({
    url: 'serviceOrders/express/'+data.type+'/details/'+data.serviceOrderId,
    method: 'get',
    params: data,
  });
}

/**
 * 提交退换货地址
 * */
export function setServiceAddress(data) {
  return fetch({
    url: 'serviceOrders/agreeReturn/' + data.serviceOrderId,
    method: 'put',
    data: data,
  });
}
